import time
from util.log_util import LogUtil

def func_log_decorator(func):
    '''
    函数装饰器，记录方法的执行时间
    '''
    def wrapper():
        start_time = time.time()
        func()
        end_time = time.time()
        execution_time = end_time - start_time
        LogUtil.info(f"Function {func.__name__} executed in {execution_time} seconds")
    return wrapper

def func_log_with_params_decorator(func):
    '''
    函数装饰器，记录方法的执行时间，修饰带参数的方法
    '''
    def wrapper(*args, **kwargs):
        start_time = time.time()
        func(*args, **kwargs)
        end_time = time.time()
        execution_time = end_time - start_time
        LogUtil.info(f"Function {func.__name__} executed in {execution_time} seconds")
    return wrapper

def func_log_decorator_with_params(log_level):
    '''
    函数装饰器，带参数的方法方法装饰器
    '''
    def log_decorator(func):
        def wrapper(*args, **kwargs):
            start_time = time.time()
            result = func(*args, **kwargs)
            end_time = time.time()
            execution_time = end_time - start_time
            print(f"{log_level}: Function {func.__name__} executed in {execution_time} seconds")
            return result
        return wrapper
    return log_decorator

def multi_decorator1(func):
    print("decorator1 before")
    def wrapper():
        print("Decorator 1")
        func()
    return wrapper

def multi_decorator2(func):
    print("decorator2 before")
    def wrapper():
        print("Decorator 2")
        func()
    return wrapper

def multi_decorator3(func):
    print("decorator3 before")
    def wrapper():
        print("Decorator 3")
        func()
    return wrapper